import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ChartSchoolVO, RoomForm, ChartSchoolQuery } from '@/api/core/home/types';

/**
 * 查询学校开出率
 * @param query
 * @returns {*}
 */

export const chartBySchool = (query?: ChartSchoolQuery): AxiosPromise<ChartSchoolVO[]> => {
  return request({
    url: '/core/panel/chartBySchool',
    method: 'get',
    params: query
  });
};
/**
 * 查询地区开出率
 * @param query
 * @returns {*}
 */

 export const chartByArea = (query?: ChartSchoolQuery): AxiosPromise<ChartSchoolVO[]> => {
    return request({
      url: '/core/panel/chartByArea',
      method: 'get',
      params: query
    });
  };
/**
 * 查询学段开出率
 * @param query
 * @returns {*}
 */
export const chartByPeriod = (query) => {
    return request({
      url: '/core/panel/chartByPeriod',
      method: 'get',
      params: query
    });
};
/**
 * 根据地区,学年,学段,学科,学校获取开课率数据
 * @returns  
 */
export const openCourseRate = (query?: ChartSchoolQuery): AxiosPromise<ChartSchoolVO[]> => {
    return request({
      url: '/core/panel/openCourseRate',
      method: 'get',
      params: query
    });
};
/**
 * 查询顶部统计数据
 * @param 
 * @returns 
 */
 export const getCountData = (): AxiosPromise<ChartSchoolVO[]> => {
    return request({
      url: '/core/panel/getCountData',
      method: 'get',
      params: {}
    });
  };

/**
 * 查询教室管理详细
 * @param id
 */
export const getRoom = (id: string | number): AxiosPromise<ChartSchoolVO> => {
  return request({
    url: '/core/room/' + id,
    method: 'get'
  });
};

/**
 * 新增教室管理
 * @param data
 */
export const addRoom = (data: RoomForm) => {
  return request({
    url: '/core/room',
    method: 'post',
    data: data
  });
};

/**
 * 修改教室管理
 * @param data
 */
export const updateRoom = (data: RoomForm) => {
  return request({
    url: '/core/room',
    method: 'put',
    data: data
  });
};

/**
 * 删除教室管理
 * @param id
 */
export const delRoom = (id: string | number | Array<string | number>) => {
  return request({
    url: '/core/room/' + id,
    method: 'delete'
  });
};

//获取省市接口
export const finProvinceList = () => {
  return request({
    url: 'core/province/finProvinceList',
    method: 'get'
  });
};
// 获取区接口 传市code {code}
export const finDistrictList = (code: string | number | Array<string | number>) => {
  return request({
    url: 'core/province/finDistrictList/' + code,
    method: 'get'
  });
};